import shopAxios from '../utils/request.js'

export async function Login(formVal) {
    const resp = await shopAxios.post('/admin/login', {
        "userName": formVal.userName,
        "passWord": formVal.passWord
    })
    return resp
}

export async function getAllList() {
    try {
        const resp = await shopAxios.get('/category/list');
        return resp;
    } catch (error) {
        console.error('Error fetching all list:', error);
        throw error; // 重新抛出错误以便在调用处捕获
    }
}

export async function getGood(id) {
    const resp = await shopAxios.get('/category/findById', {
        params: { "id": id }
    })
    return resp;
}

export async function add(addObj) {
    const resp = await shopAxios.post('/category/add', addObj)
    return resp;
}

export async function del(id) {
    const resp = await shopAxios.get('/category/deleteById', {
        params: { "id": id }
    })
    return resp;
}

export async function update(newObj) {
    const resp = await shopAxios.post('/category/update', newObj)
    return resp;
}